package acm.天梯赛4;

import java.util.Scanner;

public class C {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while (sc.hasNext()) {
            int n = sc.nextInt();
            int r = sc.nextInt();
            System.out.println(Integer.toString(n , r).toUpperCase());
        }
    }
}
